package top.broncho.lottery.api

import retrofit2.Call
import retrofit2.http.GET
import retrofit2.http.Headers
import retrofit2.http.Query
import top.broncho.lottery.BuildConfig
import top.broncho.lottery.model.BaseResponse
import top.broncho.lottery.model.history.LotteryHistory
import top.broncho.lottery.model.lottery.Lottery

const val BASE_URL = "http://apis.juhe.cn"
const val LOTTERY_ID = "ssq"

interface LotteryApi {

    @Headers("$DOMAIN_NAME: $BASE_URL")
    @GET("/lottery/query")
    suspend fun query(
        @Query("lottery_no") lotteryNo: String,
        @Query("lottery_id") lotteryId: String = LOTTERY_ID,
        @Query("key") key: String = BuildConfig.LOTTERY_APP_KEY
    ): BaseResponse<Lottery>

    @Headers("$DOMAIN_NAME: $BASE_URL")
    @GET("/lottery/query")
    suspend fun queryLatest(
        @Query("lottery_id") lotteryId: String = LOTTERY_ID,
        @Query("key") key: String = BuildConfig.LOTTERY_APP_KEY
    ): BaseResponse<Lottery>

    @Headers("$DOMAIN_NAME: $BASE_URL")
    @GET("/lottery/history")
    suspend fun history(
        @Query("page") page: Int,
        @Query("page_size") pageSize: Int = 50,
        @Query("lottery_id") lotteryId: String = LOTTERY_ID,
        @Query("key") key: String = BuildConfig.LOTTERY_APP_KEY
    ): BaseResponse<LotteryHistory>

    @Headers("$DOMAIN_NAME: $BASE_URL")
    @GET("/lottery/history")
    fun getHistory(
        @Query("page") page: Int,
        @Query("page_size") pageSize: Int = 50,
        @Query("lottery_id") lotteryId: String = LOTTERY_ID,
        @Query("key") key: String = BuildConfig.LOTTERY_APP_KEY
    ): Call<BaseResponse<LotteryHistory>>
}